import { Nodes } from '@knno/dom';
import { PaginatorEventMap, Paginator as UIPaginator } from '../components/paginator/paginator';
import { JSXProps } from '@knno/dom/jsx';
import { AttrCheck, On, isNumber, jsxBuild } from './utils';

export { UIPaginator };

interface PaginatorProps extends JSXProps<UIPaginator>, On<PaginatorEventMap, UIPaginator> {
	pages?: number;
	active?: number;
	buttons?: number;
}

const ATTRS: AttrCheck = {
	pages: isNumber,
	active: isNumber,
	buttons: isNumber,
};

export function Paginator(props: PaginatorProps, children: Nodes[]): UIPaginator {
	return jsxBuild(new UIPaginator(), props, children, ATTRS);
}
